<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no" />
  <title>首页</title>
  <!-- <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" /> -->
</head>

<body>
  <canvas id="canvas" width="300" height="300"></canvas>
</body>

</html>
<script>
  // 找到画布
  let canvas = document.querySelector("#canvas")
  // 获取画笔
  let ctx = canvas.getContext('2d')
  // 绘制
  ctx.rect(0, 0, 300, 300)
  ctx.fillStyle = 'pink'
  // 渲染
  ctx.fill()
  //  描边
  ctx.lineWidth = 2
  ctx.strokeStyle = '#f00'
  ctx.stroke()
</script>